// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import 'normalize.css'
import IView from 'iview'
import '../../../node_modules/vue2-lazy-tree/dist/vue2-tree.min.css'
import 'iview/dist/styles/iview.css'
import '../../assets/common/styles/common.less'
import '../../assets/admin/styles/modify.less'
import App from './App'
import router from '../../router/admin.js'
import store from '../../store/admin/index'
import { ZTree } from 'vue2-lazy-tree'
import ZkTable from 'vue-table-with-tree-grid'
import {isConfirm} from '../../assets/admin/js/common'
import rules from '../../assets/admin/js/rules.js'

store.dispatch('getMenu')

Vue.config.productionTip = false
Vue.prototype.$rules = rules
Vue.prototype.$isConfirm = isConfirm
Vue.use(IView)
Vue.component('ztree', ZTree)
Vue.component(ZkTable.name, ZkTable)

router.beforeEach((to, from, next) => {
  if (to.matched.length === 0) {
    from.name ? next({ name: from.name }) : next('/')
  } else {
    next()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
